package pers.hl.lib_global.common

import java.text.SimpleDateFormat
import java.util.*

object Const {

    const val DEFAULT_BAR_CODE_INT = -0x10000
    const val DEFAULT_BAR_CODE_LONG = -10000L

    // 笔记本
//    const val LIB_URL = "http://172.31.15.131:8091/library/"
    // 笔记本盒子网
    const val LIB_URL = "http://192.168.43.8:8091/library/"
//    const val LIB_URL = "http://192.168.1.14:8091/library/"
//    const val LIB_URL = "http://192.168.0.100:8091/library/"
    // 台式
//    const val LIB_URL = "http://192.168.0.102:8091/library/"
    // 外网
//    const val LIB_URL = "http://zhoujuncai.vicp.io/library/"

    const val WAN_URL = "https://www.wanandroid.com/"
    const val DOUBAN_BOOK_API_URL = "https://api.douban.com/v2/book/"
    const val DOUBAN_BOOK_WEB_SEARCH_URL =
        "https://book.douban.com/subject_search?search_text=%s&cat=1001"
    const val API_KEY_DOUBAN = "054022eaeae0b00e0fc068c0c0a2102a"

    /**
     * 图片下载地址，第一个参数图片类型，第二个参数业务id
     */
    const val IMAGE_DOWNLOAD_URL = LIB_URL + "file/download/%s/%s"

    const val LIST_BY_KEY_URL = "listByKey/{key}/{value}"

    const val HTTP_CODE_SUCCESS: Int = 0
    const val HTTP_CODE_LOGIN_EXPIRED = -401
    const val HTTP_CODE_ERROR = -1

    /**
     * 消息事件
     */
    object MessageEvent {
        /**
         * token过期
         */
        const val EVENT_TOKEN_EXPIRED = "event_token_expired"

        /**
         * exception发生
         */
        const val EVENT_EXCEPTION_OCCURRED = "event_exception_occurred"

        /**
         * 书籍信息改变
         */
        const val EVENT_BOOK_INFO_CHANGE = "event_book_info_change"
    }

    object KEY {
        const val KEY_AUTHORIZATION = "Authorization"
        const val KEY_TOKEN = "key_token"
        const val KEY_LOGIN = "key_login"
        const val KEY_USER = "key_user"
        const val NEED_LOGIN = "need_login"
        const val KEY_SAVE_PASSWORD = "key_save_password"
        const val KEY_DATA_COMMON_EDIT = "key_data_common_edit"
        const val KEY_DATA_COMMON_BUNDLE = "key_data_common_bundle"
    }

    object RequestParam {
        const val PARAM_PAGE_SIZE = "pageSize"
        const val PARAM_PAGE_NUM = "pageNum"

        const val DEFAULT_PAGE_SIZE = 20
        const val DEFAULT_PAGE_NUM = 1

    }

    object NotificationKeys {
        const val KEY_EXPIRING_BORROWS = "key_expiring_borrows"
        const val ID_EXPIRING_BORROWS = 0x01
    }

    object DateFormat {
        val FORMAT_YYYY_MM_DD = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA)
    }
}